/**
 * 
 */
package us.gaaoc.framework.dao;

import org.hibernate.FetchMode;
import org.hibernate.HibernateException;
import org.hibernate.criterion.Restrictions;

import us.gaaoc.framework.model.Address;
import us.gaaoc.framework.model.AddressCategory;

/**
 * @author Sukhada Tapshalkar
 *
 * Dec 4, 2007
 *
 * GAJE_BibbCounty_2.0
 *
 */
public class AddressCategoryDAOHibernate extends GenericHibernateDAO<AddressCategory, Integer,AddressCategoryDAO> 
implements AddressCategoryDAO{

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.AddressCategoryDAO#findAddressCateory(us.gaaoc.framework.model.AddressCategory)
	 */
	public AddressCategory findAddressCateory(int addressCategoryCode) {
		AddressCategory addressCategory = null;
		try {
			// eagerly fetch the AddressCategory object
			addressCategory = (AddressCategory) getSession().createCriteria(AddressCategory.class)
				.setFetchMode("*", FetchMode.SELECT)
				.add(Restrictions.eq("code", addressCategoryCode))
				.uniqueResult();
		} catch (HibernateException e) {
			LOG.error(e);
			throw e;
		}
		return addressCategory;
	}

}
